import {
	createPinia
} from 'pinia'
import {
	createPersistedState
} from 'pinia-plugin-persistedstate'

const pinia = createPinia()

const modules = import.meta.glob('./modules/*.js', {
	eager: true
})

pinia.use(createPersistedState({
	storage: {
		getItem: (key) => uni.getStorageSync(key),
		setItem: (key, value) => uni.setStorageSync(key, value),
		removeItem: (key) => uni.removeStorageSync(key)
	}
}))

export default pinia

export const orderStore = modules['./modules/orderStore.js'].default
export const orderMsg = modules['./modules/orderMsg.js'].default
export const loginToken = modules['./modules/loginToken.js'].default
export const userStore = modules['./modules/userStore.js'].default